﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TestMenu
{
    public partial class _Default : System.Web.UI.Page
    {
        static string testStr = "Quang";
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = testStr;
            List<TempBean> lstData = new List<TempBean>();
            for (int i = 0; i < 5; i++)
            {
                TempBean t = new TempBean();
                t.Id = i;
                t.Stt = i + 1;
                List<Attachment> lstAt = new List<Attachment>();
                for (int j = 0; j < 3; j++)
                {
                    Attachment t1 = new Attachment();
                    t1.Id = 1;
                    t1.Name = "Attach file " + j.ToString();
                    lstAt.Add(t1);
                }
                t.LstAttachment = lstAt;
                lstData.Add(t);
            }
            dgvApprover.DataSource = lstData;
            dgvApprover.DataBind();

        }
        protected void onDgvDatabind(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TempBean data = (TempBean)e.Row.DataItem;
                Repeater rpt = (Repeater)e.Row.Cells[2].FindControl("Repeater1");
                rpt.DataSource = data.LstAttachment;
                rpt.DataBind();
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            testStr = TextBox1.Text;
        }

        protected void downloadAttach(object sender, EventArgs e)
        {
        }

    }
    public class TempBean
    {
        private int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        private int stt;

        public int Stt
        {
            get { return stt; }
            set { stt = value; }
        }
        private List<Attachment> lstAttachment;

        public List<Attachment> LstAttachment
        {
            get { return lstAttachment; }
            set { lstAttachment = value; }
        }


    }
    public class Attachment
    {
        private int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

    }
}
